<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use Hash;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use PDO;
class DengluController extends Controller
{
    public function getIndex()
    {
    	  // echo '111111';
    	//解析模板
    	 return view('denglu.login');
    }

    public function postInsert(Request $request)
    {
        // echo 4444444444;
         // dd($request->all());
        // $data = $request->only(['username','password']);
        $username = $request->input('username');

       // $request->input('password');

        $res = DB::table('users')->where('username',$username)->first();
        // dd($res);
         // dd($res->password);
        // $pass = DB::table('users')->where('password')->select();
        // dd($pass);
        if(!empty($res)){
            // dd($res->password);
            if(Hash::check($request->input('password'),$res->password)){
                session(['id' =>$res->id]);
                return redirect('/admin')->with('success','欢迎-- '.$username.' --登录');
                // echo 1222222;
            }else{
                return back()->with('error','用户名或密码不正确');
            }

            // echo 111111;
        }else{
            return back()->with('error','用户名或密码不正确');
        }



    }   

   

}
